package org.jmetrix.samples.application;

import org.jmetrix.monitor.impl.SimpleMonitor;

/**
 * @author Konstantin Kuzmin
 * @version $Revision$
 * @since 10.03.12
 */
public class SimpleMonitorSample {
    public static final OrderManager orderManager = new OrderManager();

    public static void main(String[] args) throws Exception {
        // Create and start performance monitor
        SimpleMonitor simpleMonitor = new SimpleMonitor();
        simpleMonitor.start();

        try {
            // Do some OrderManager calls
            orderManager.processOrder(new Order(200));
            orderManager.processOrder(new Order(300));

            // Pause just to make sure that performance metrics has been processed (asynchronously)
            Thread.sleep(100);

            // Output performance metrics
            System.out.println("Performance metrics: " + simpleMonitor.getMetrixAggregator());
        } finally {
            // Stop the performance monitor (not necessary)
            simpleMonitor.stop();
        }
    }
}
